<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="<?=base_url()?>public/css/style1.css" />
<script type="text/javascript" src="<?=base_url()?>public/js/jq.1.12.4.js"></script>
<script type="text/javascript" src="<?=base_url()?>public/js/js.js"></script>
<title>忘记密码</title>
<style>
	.content_box p span{
		width:22%;
	}
	b{
		height:12px;
	}
</style>
</head>
<body >
<div class="bg1">
   <div class="logo1">
   	<div class="logo1_box">
   		<img src="<?=base_url()?>public/img/logo.png" /><span>公益扶农合作平台</span>
    </div>
   </div>
   <div class="content">
   
   	<div class="content_box" style="padding-top:50px;">
   	<?php echo form_open('forget/update_pwd',array('id'=>'myform')); ?>
		<p style='margin-left:31%;'>
			<input type="radio" name="pwd_type" value="pwd" checked="checked" id='radio' />找回登录密码
			<input type="radio" style='margin-left:8%' name="pwd_type" value="spwd" id='radio1' />找回二级密码
		</p>
   		<p class="one"><span class='nue-pasw'>新登录密码</span><input id="new_pwd" name="new_pwd" type="password"  /></p>
        	<b class='psw_js'></b>
        <p class="one"><span>验证手机号</span><input id="mobile" name="mobile" type="text" placeholder="" style='width:50%;' />
        	<input id="send_yzm" type="button" value="获取验证码" style='width:20%;'></p>
        	<b class='phon'></b>
        <p class="one"><span>验证码</span><input id="yzm" name="yzm" type="text" placeholder="" /></p>
        <p class="btn"><input id="zhaohui" style="width:30%; background:#254e01; color:white; margin-left:40%; margin-top:40px; margin-left:40%;" type="button" value="确认找回"></p>
	</form>
   	</div>
   </div>
</div>
<script>
$('body').css('height',$(window).height());
</script>

<script type="text/javascript">
$(function(){
	$('#radio').click(function(){
		$('.nue-pasw').text('新登录密码');
	})
	$('#radio1').click(function(){
		$('.nue-pasw').text('新二级密码');
	})
	var phon = /^1[3458]\d{9}$/;
	
  $('#zhaohui').on('click', function(event) {
	 if($(":radio:checked").attr("id")=="radio"){
		 if($('#new_pwd').val() == ''){
				$('.psw_js').text('新登录密码不得为空');
				return false;
			}else{
				$('.psw_js').text('');
			}
			if($('#new_pwd').val().length < 6){
				$('.psw_js').text('登录密码长度不得少于6位');
				return false;
			}else{
				$('.psw_js').text('');
			}
			if($('#new_pwd').val().length > 20){
				$('.psw_js').text('登录密码长度不得少于6位');
				return false;
			}else{
				$('.psw_js').text('');
			}
		 }else{
			  //密码
			if($('#new_pwd').val() == ''){
				$('.psw_js').text('新二级密码不得为空');
				return false;
			}else{
				$('.psw_js').text('');
			}
			if($('#new_pwd').val().length < 6){
				$('.psw_js').text('二级密码长度不得少于6位');
				return false;
			}else{
				$('.psw_js').text('');
			}
			if($('#new_pwd').val().length > 20){
				$('.psw_js').text('二级密码长度不得少于6位');
				return false;
			}else{
				$('.psw_js').text('');
			}	 
		 }

   
	
    //手机号
    if(!phon.test($('#mobile').val())){
		$('.phon').text('请输入正确的手机号');
		return false;
    }else{
		$('.phon').text('');
	}

    $('#myform').submit();
    
  });

  
	var InterValObj;//time
	var count = 60;
	var curCount;
	  
	  //通过短信接口向手机发送短信
	$('#send_yzm').on('click',  function(event) {
	  	//手机号
	    if(!phon.test($('#mobile').val())){
			$('.phon').text('请输入正确的手机号');
			return false;
	    }else{
			$('.phon').text('');
		}
	    curCount = count;
		$('#send_yzm').attr('disabled','true');
		$('#send_yzm').val(curCount+'秒内输入');
		InterValObj = setInterval(SetRemainTime,1000);
		
	    var url = '<?php echo site_url("reg/ajax_send_check_code") ?>';
	    $.post(url, {mobile: $('#mobile').val()}, function(d) {
	      if(d.err > 0){
			  //$('.js-tishi').css('display','block');
		  // $('.js-tishi').text('提交成功');
	      	alert('提交成功');
	        //$('#sms_code').val(d.code);
	      }else{
	        alert(d.msg);
	      }
	    });
	    //dosomething
	    //var code = 123456;

	    //$('#sms_code').val(code);

	  });
	  function SetRemainTime(){
			if(curCount == 0){
				clearInterval(InterValObj);
				$('#send_yzm').removeAttr('disabled');
				$('#send_yzm').val('发送验证码')
			}else{
				curCount--;
				//console.log(curCount)
				$('#send_yzm').val(curCount+'秒内输入');
			}
		}
})
</script>

</body>
</html>